package arkham.gui;

import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JLabel;

public class UnderlinedLabel extends JLabel {

	private static final long serialVersionUID = 2967714330765773175L;

	public UnderlinedLabel() {
		this("");
	}

	/**
	 * Creates a new underlined label with the specified text
	 * @param text the text to display
	 */
	public UnderlinedLabel(String text) {
		super(text);
	}

	/**
	 * Creates a new underlined label with the specified text and alignment
	 * @param text the text to display
	 * @param alignment the alignment of the text
	 */
	public UnderlinedLabel(String text, int alignment)
	{
	    super(text, alignment);
	}

	public void paint(Graphics g) {
		Rectangle r;
		super.paint(g);
		r = g.getClipBounds();
		int heightMod = getFontMetrics(getFont()).getHeight() / 22;
		g.drawLine(0,
				r.height + heightMod - getFontMetrics(getFont()).getDescent(),
				getFontMetrics(getFont()).stringWidth(getText()),
				r.height + heightMod - getFontMetrics(getFont()).getDescent());
	}
}
